package com.meixun.xuanke.course.service.impl;

import com.alibaba.fastjson.JSON;
import com.meixun.xuanke.course.model.MqCourseInfo;
import com.meixun.xuanke.course.service.ActiveMQService;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jms.Destination;
@Service
public class ActiveMQServiceImpl implements ActiveMQService {

    @Resource
    private JmsTemplate jmsTemplate;

    //ActiveMQQueue 队列模式
    //ActiveMQTopic 订阅模式

    Destination addCourseDestination = new ActiveMQQueue("mq.studentCourse");


    @Override
    public void addCourse(MqCourseInfo mqCourseInfo) {
        jmsTemplate.convertAndSend(addCourseDestination, JSON.toJSON(mqCourseInfo).toString());
    }
}
